package com.zhejiangzhengyuan.municipal_common.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhejiangzhengyuan.municipal_common.entity.MaintenanceRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhejiangzhengyuan.municipal_common.entity.vo.MaintenanceManageVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 该表不作为交互业务直接写入，而是由道路或桥梁养护任务完成时，由养护任务内容数据进行同步，并关联上养护目标（桥梁或道路）；
 * 养护记录虽然存在与道路或桥梁表的关联，但是不存在直接的物理外键关系，所以这里没有外键约束 Mapper 接口 <<<<<<< HEAD ======= >>>>>>> ergouzi
 *
 * @author linju
 * @since 2019-11-22
 */
@Repository
public interface MaintenanceRecordMapper extends BaseMapper<MaintenanceRecord> {

  int selectChartByTimestamp(
      @Param("startTimestamp") String startTimestamp, @Param("endTimestamp") String endTimestamp);

  @Select(
      "select mr.*,f.link,f.origin_name\n"
          + "        from maintenance_record mr,maintenance_record_file_mapping mfm,file f\n"
          + "        where mr.id=mfm.maintenance_record_id and mfm.file_id=f.id ORDER BY mr.id")
  Page<MaintenanceManageVo> selectMaintenanceManageVoPage(Page<MaintenanceManageVo> page);

  @Select(
      "select mr.*,f.link,f.origin_name\n"
          + "        from maintenance_record mr,maintenance_record_file_mapping mfm,file f\n"
          + "        where mr.id=mfm.maintenance_record_id and mfm.file_id=f.id ORDER BY mr.id")
  List<MaintenanceManageVo> selectMaintenanceManageVo();

  Page<MaintenanceManageVo> maintenanceFuzzy(
      Page<MaintenanceManageVo> maintenanceManagePage,
      @Param("iLocation") String name,
      @Param("userInfo") String userInfo,
      @Param("startTimestamp") String startTimestamp,
      @Param("endTimestamp") String endTimestamp);
}
